"""
author: Jackson Black
time: 2023-08-20 10-55-45 
"""


# 单行str 多行str 转义字符
def str_primary():
    str_single = 'Jason Black'
    str_more = '''
        Jason
        Black  '''
    str_translate = 'My name isn\'t Jason'
    print(
        f'str_single = {str_single}\n'
        f'str_more = {str_more}\n'
        f'str_translate = {str_translate}\n'
    )


# %方式  format方式  f方式
def str_format():
    a, b = 13, 15
    print('百分号方式: %d + %d = %d' % (a, b, a + b))
    # 默认 {0} + {1} = {2}  可手动改变位置
    print('format方式: {} + {} = {}'.format(a, b, a + b))
    print(f'f方式: {a} + {b} = {a + b}')


# 常用api  索引、切片
def str_api():
    str_ = 'Jason'
    print(str_.upper())
    print(str_.lower())
    print(str_.isalpha())
    print(str_.isalpha())
    print(str_[:3], str_[4])


if __name__ == '__main__':
    # str_primary()
    # str_format()
    str_api()
